<template>
  <van-dialog
    v-model="isShow"
    title=""
    show-cancel-button
    confirm-button-color="#548AF1"
    @cancel="closeDialog"
    @confirm="confirmRule"
  >
    <div class="skuDilog-header">批次号选择</div>
    <div class="content">
        <div class="content-item" :class="{bg:item.chose}" v-for="(item,index) in data" :key="index" @click="choseData(item)">
        <span class="text" v-if="item.barCode">{{item.barCode}}</span>
        <span class="text" v-if="item.materialFields.name">{{item.materialFields.name}} </span>
        <span class="text" v-if="item.skuName">{{item.skuName}} </span>
        <span class="count">{{item.stockLocationQuantity}}</span>
      </div>
    </div>
  </van-dialog>
</template>
<script>
import { Dialog } from "vant";
export default {
  data() {
    return {};
  },
  components: {
    [Dialog.Component.name]: Dialog.Component,
  },
  props:{
    data:{
        type:Array,
        default:()=>{
            return []
        }
    },
    show:{
        type:Boolean,
        default:false
    }
  },
  computed:{
    isShow:{
        get(){
            return this.show
        },
        set(val){
            this.$emit("update:show", val);
        }

    }
  },
  methods:{
    choseData(item){
        this.data.map(i=>{ delete i.chose})
        item.chose = true
        this.data.splice()
        
    },
    closeDialog(){
        this.isShow = false
    },
    confirmRule(){
        const data = this.data.filter(item=>item.chose)
        this.$emit('confirm',data)
    }
  }
};
</script>
<style scoped lang="scss">
.skuDilog-header {
  padding: 14px 21px;
  font-size: 15px;
  font-family: Source Han Sans CN-Medium, Source Han Sans CN;
  font-weight: 500;
  color: #333333;
  position: relative;
  &::after {
    display: block;
    position: absolute;
    content: "";
    width: 4px;
    height: 14px;
    border-radius: 1px;
    background: #548af1;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
  }
}
.content {
  padding: 10px;
  .content-item {
    // background: #F7F7F7;
    padding: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    &.bg{
        background: #F7F7F7
    }
    .text {
      font-size: 14px;
      font-family: Source Han Sans CN-Regular, Source Han Sans CN;
      font-weight: 400;
      color: #333333;
    }
    .count {
      font-size: 14px;
      font-family: Source Han Sans CN-Regular, Source Han Sans CN;
      font-weight: 400;
      color: #548af1;
    }
  }
}
</style>